// 测试数据初始化
import localStorage from './storage.js'

export function initTestData() {
    // 检查是否已有测试用户
    const users = uni.getStorageSync('memo_users') || []
    if (users.length > 0) {
        console.log('测试数据已存在')
        return
    }
    
    // 创建测试用户
    const testUser = {
        username: '13800138000',
        name: '测试用户',
        phone: '13800138000',
        password: '123456',
        agreeProtocol: true
    }
    
    const result = localStorage.register(testUser)
    
    if (result.success) {
        console.log('测试用户创建成功:', result.data.userInfo)
    } else {
        console.log('测试用户创建失败:', result.message)
    }
}

// 清除所有数据（调试用）
export function clearAllData() {
    uni.removeStorageSync('memo_users')
    uni.removeStorageSync('memo_current_user')
    uni.removeStorageSync('memo_data')
    uni.removeStorageSync('memo_token')
    uni.removeStorageSync('rememberedAccount')
    console.log('所有数据已清除')
}

export default {
    initTestData,
    clearAllData
} 